package com.example.reagent_management.room.entity;

import java.util.Calendar;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;

//primaryKeys = {"name","type","batch_number"},
/*
*
* foreignKeys = {@ForeignKey(
                entity = ReagentInformation.class,
                parentColumns = "id",
                childColumns = "reagent_id",onUpdate = ForeignKey.CASCADE,onDelete = ForeignKey.NO_ACTION)}
* */
@Entity(tableName = "operate")
public class ReagentOperate {

    @PrimaryKey(autoGenerate = true)
    @ColumnInfo(name = "id")
    private Long id;
    //批号
    @ColumnInfo(name = "batch_number")
    private String batchNumber;
    //供应商
    @ColumnInfo(name = "supplier",defaultValue = "null")
    private String supplier;
    //有效天数
    @ColumnInfo(name = "days")
    private Long days;
    //试剂信息 db_id
    @ColumnInfo(name = "reagent_info")
    private Long reagent_info;
    //操作类型 0 1  true 1为入库
    @ColumnInfo(name = "operate")
    private Boolean operate;
    //库存变动数量 目前统计的是(试剂批号+试剂信息id唯一的变化数) 只体现在记录页上，只记录在入库上
    //出库时关联入库ID
    @ColumnInfo(name = "counts")
    private Long counts = 0L;
    //出入库数
    @ColumnInfo(name = "num")
    private Long num = 0L;

    public Long getCounts() {
        return counts;
    }

    public void setCounts(Long counts) {
        this.counts = counts;
    }

    @Ignore
    public ReagentOperate() {
    }

    /**
     * 入库
     * @param batchNumber 批号
     * @param supplier  供应商 可空
     * @param days  有效天数/出库日期
     * @param reagent_info 试剂信息id
     * @param operate  操作类型
     * @param counts    库存数量
     */
    public ReagentOperate(String batchNumber, String supplier, Long days, Long reagent_info, Boolean operate, Long counts,Long num) {
        this.batchNumber = batchNumber;
        this.supplier = supplier;
        //有效天数
        this.days =  Calendar.getInstance().getTime().getTime() + days*24*60*60*1000;
        this.reagent_info = reagent_info;
        this.operate = operate;
        this.counts = counts;
        this.num = num;
    }



    public Long getNum() {
        return num;
    }

    public void setNum(Long num) {
        this.num = num;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBatchNumber() {
        return batchNumber;
    }

    public void setBatchNumber(String batchNumber) {
        this.batchNumber = batchNumber;
    }

    public String getSupplier() {
        return supplier;
    }

    public void setSupplier(String supplier) {
        this.supplier = supplier;
    }

    public Long getDays() {
        return days;
    }

    public void setDays(Long days) {
        this.days = days;
    }

    public Long getReagent_info() {
        return reagent_info;
    }

    public void setReagent_info(Long reagent_info) {
        this.reagent_info = reagent_info;
    }

    public Boolean getOperate() {
        return operate;
    }

    public void setOperate(Boolean operate) {
        this.operate = operate;
    }

    @Override
    public String toString() {
        return "ReagentOperate{" +
                "id=" + id +
                ", batchNumber='" + batchNumber + '\'' +
                ", supplier='" + supplier + '\'' +
                ", days=" + days +
                ", reagent_info=" + reagent_info +
                ", operate=" + operate +
                ", counts=" + counts +
                '}';
    }
}
/*
* 试剂
*  复合主键 试剂名和类型和批号 同一试剂名称可以对应不同的类型
*   关联  试剂信息名称变更时试剂也变更 试剂信息删除时试剂不删除
* */
